import axios from 'axios';

export function ajax(url, data={}, method='GET') {
    return new Promise((resolve, reject) => {
        let promise;

        if (method === 'GET') {
            promise = axios.get(url, {
                params: data,
            });
        } else {
            promise = axios(url, data);
        };

        promise.then(response => {
            resolve(response);
        }). catch(err => {
            reject(err);
        })
    });
};